Skip to content

Conversation

@koralkulacoglu
Copy link
Contributor

Ticket: DX-1373

@koralkulacoglu koralkulacoglu requested a review from a team as a code owner November 6, 2025 16:03
@koralkulacoglu koralkulacoglu marked this pull request as draft November 6, 2025 19:51
@BitGo BitGo deleted a comment from Copilot AI Nov 10, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for preserving individual enum variant descriptions when generating OpenAPI specifications. The implementation ensures that when enums have JSDoc comments on individual properties, these descriptions are maintained in the generated oneOf schemas rather than being consolidated.

  • Preserves per-variant comments in keyof-based enums through the IR
  • Prevents consolidation of enum values that have individual descriptions
  • Extracts enum descriptions from array items to parameter level when appropriate

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/openapi-generator/test/openapi/comments.test.ts Adds two test cases verifying enum description preservation: one with individual variant descriptions (oneOf) and one with a single enum description
packages/openapi-generator/src/knownImports.ts Updates keyof handler to preserve comments from object properties when creating enum schemas
packages/openapi-generator/src/optimize.ts Modifies simplifyUnion to skip consolidation of enum literals that have associated comments
packages/openapi-generator/src/openapi.ts Adds logic to extract descriptions from array items and move them to the parameter level for better API documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@koralkulacoglu koralkulacoglu marked this pull request as ready for review November 12, 2025 18:59
Implement support for individual enum variant descriptions using the
x-enumDescriptions OpenAPI extension. This provides cleaner OpenAPI
specs compared to the oneOf approach and is better supported by
documentation tools like README.com.

Changes:
- Add enumDescriptions property to Primitive schema type
- Update keyof handler to detect individual enum descriptions
- Generate x-enumDescriptions extension in OpenAPI output
- Preserve enum descriptions during optimization
- Add comprehensive tests for both scenarios:
  * Enums with descriptions use x-enumDescriptions extension
  * Enums without descriptions use standard enum format

All tests passing (188/188)
@koralkulacoglu koralkulacoglu force-pushed the DX-1373-Support-enum-variant-descriptions branch from 211379e to 836e43c Compare November 13, 2025 20:55
@koralkulacoglu koralkulacoglu self-assigned this Nov 13, 2025
Copy link
Contributor

@starfy84 starfy84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@starfy84 starfy84 merged commit 50f51e5 into master Nov 13, 2025
6 checks passed
@starfy84 starfy84 deleted the DX-1373-Support-enum-variant-descriptions branch November 13, 2025 22:00
@github-actions
Copy link

🎉 This PR is included in version @api-ts/openapi-generator@5.11.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants